package com.wenhai.concurrency.thread.pool;

import java.util.concurrent.Callable;

/**
     * @ClassName MyCallableB
 * @Description
 * @Author 谢文海
 * @Date 2021/4/27 0:41
 * @Version 1.0
 **/
public class MyCallableBInterrupted implements Callable<String> {
    @Override
    public String call() throws Exception {
        System.out.println(" MyCallableBInterrupted begin " + System.currentTimeMillis());
        for (int i = 0; i < 111223456; i++) {
            if (!Thread.currentThread().isInterrupted()) {
                Math.random();
                Math.random();
                Math.random();
//                System.out.println("MyCallableBInterrupted 在运行总 = " + (i + 1));
            } else {
                System.out.println("*******************************抛出异常中断了");
                throw new InterruptedException();
            }

        }
        System.out.println("MyCallableBInterrupted end " + System.currentTimeMillis());
        return "Return BInterrupted";
    }
}
